//
//  LSZTopicTableViewCell.m
//  JKFuYinProject
//
//  Created by 九酷 on 2018/8/23.
//  Copyright © 2018年 LC. All rights reserved.
//

#import "LSZTopicTableViewCell.h"

@implementation LSZTopicTableViewCell

-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.imageViewIcon = [[UIImageView alloc]init];
        CGFloat heightImage = [LSZSpecialPackaging initWithReturnsthesizeOf:60 :5];
        self.imageViewIcon.frame = CGRectMake(10, 10, heightImage, heightImage);
        [self addSubview:self.imageViewIcon];

        CGFloat heightLabel = [LSZSpecialPackaging initWithReturnsthesizeOf:22 :2];
        CGFloat heightLabelNum = [LSZSpecialPackaging initWithReturnsthesizeOf:18 :2];

        self.labelTitle = [[UILabel alloc]init];
        self.labelTitle.numberOfLines = 0;
        self.labelTitle.frame = CGRectMake(CGRectGetMaxX(self.imageViewIcon.frame)+15, CGRectGetMinY(self.imageViewIcon.frame)+(self.imageViewIcon.frame.size.height-heightLabel-heightLabelNum-5)/2, ScreenWidth-CGRectGetMaxX(self.imageViewIcon.frame)-20,heightLabel);
        self.labelTitle.textColor = titleColorLSZ;
        [LSZSpecialPackaging setLabelAdaptiveSize:self.labelTitle font:17];
        [self addSubview:self.labelTitle];

        self.labelNumber = [[UILabel alloc]init];
        self.labelNumber.frame = CGRectMake(CGRectGetMaxX(self.imageViewIcon.frame)+15, CGRectGetMaxY(self.labelTitle.frame)+5, ScreenWidth-CGRectGetMaxX(self.imageViewIcon.frame)-10, heightLabelNum);
        self.labelNumber.textColor = lightColor;
        [LSZSpecialPackaging setLabelAdaptiveSize:self.labelNumber font:14];
        [self addSubview:self.labelNumber];
    }
    return self;
}
-(void)setListTopicsMg:(LSZListTopicsMg *)listTopicsMg
{
    NSString *decodeString = [listTopicsMg.img stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    [self.imageViewIcon sd_setImageWithURL:[NSURL URLWithString:decodeString] placeholderImage:[UIImage imageNamed:@"placeholder"]];

    self.labelTitle.text = [NSString stringWithFormat:@"#%@#",listTopicsMg.content];
    self.labelNumber.text = [NSString stringWithFormat:@"%@ 人参与",listTopicsMg.num];
    CGFloat size = [LSZSpecialPackaging initWithReturnsthesizeOf:17 :0.5];
    CGFloat heightTitle = [LSZSpecialPackaging caculateHeightOfText:self.labelTitle.frame.size.width-10 height:ScreenHeight font:size :listTopicsMg.content]-20;

    CGFloat height = [LSZSpecialPackaging initWithReturnsthesizeOf:58+heightTitle :5];
    CGRect rect2 = self.imageViewIcon.frame;
    rect2.origin.y = (height-self.imageViewIcon.frame.size.height)/2;
    self.imageViewIcon.frame = rect2;

    CGRect rect = self.labelTitle.frame;
    rect.size.height = heightTitle;
    self.labelTitle.frame = rect;

    CGRect rect1 = self.labelNumber.frame;
    rect1.origin.y = CGRectGetMaxY(self.labelTitle.frame)+5;
    self.labelNumber.frame = rect1;
}
@end
